package com.woniuxy01;

import java.io.*;

/**
 * @author 作者
 * @create 2025-09-18 11:35
 */
public class Test01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        loadObject();
    }

    private static void loadObject() throws IOException, ClassNotFoundException {
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("stu.bin"));
        Stu stu = (Stu) ois.readObject();
        System.out.println(stu);
        ois.close();
    }

    private static void savaObject() throws IOException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("stu.bin"));
        Stu stu=new Stu(1,"zs",11,"cd",new School("school001"));
        oos.writeObject(stu);
        oos.close();
    }
}
